package com.study.langchain4j.api;

import com.study.langchain4j.service.MemoryChatService;
import dev.langchain4j.data.message.AiMessage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xl-9527
 * @since 2025/10/31
 */
@RestController
@RequestMapping("ai/memory-chat")
public class MemoryChatApi {

    private final MemoryChatService memoryChatService;

    public MemoryChatApi(final MemoryChatService memoryChatService) {
        this.memoryChatService = memoryChatService;
    }

    @GetMapping("/hello")
    public Object hello(@RequestParam("userId") Object userId, @RequestParam("userMessage") String userMessage) {
        final AiMessage hello = memoryChatService.hello(userId, userMessage);
        return hello.text();
    }
}
